<template>
</template>
<script>
	import * as orderTypeCode from "../../config/orderTypeCode";
	import getAppVersion from "../../utils/gw/getAppVersion";
    export default {
        data() {
            return {
				defaultVersion: "0.0.0"
            }
		},
		computed: {
			orderNo() {
				return this.$route.params.orderNo;
			},
			//订单类型，线上订单为2（跳转到待配送），线下订单为1（跳转到全部）,礼品卡为12
			orderType() {
				return this.$route.params.orderType;
			},
			//获取设备类型
			phoneType() {
				let u = navigator.userAgent;
				let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android
				let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios
				return isAndroid ? "Android" : "iOS";
			},
			//判断是否在象谱内
			isXiangpu() {
				return navigator.userAgent.indexOf("xiangpu") > -1;
			},
		},
        methods: {
			//在vuex中置一个标志位为true，用来监控原生back键的返回
			setNativeBackFlagForPayIsTrue() {
				this.$store.commit("setNativeBackFlagForPay", true);
			}
        },
        async created() {
			console.log("this.orderType", this.orderType);
            // let flag = await this.judgeAppVersionisHigher();
            let flag = await getAppVersion("_pay_version");
			console.log("是否启用新的支付流程", flag);
			try {
				if (flag) {
					this.$router.replace({name: "newPay", params: {
						...this.$route.params
					}});
				} else {
					this.$router.replace({name: "oldPay", params: {
						...this.$route.params
					}});
				}
			} catch(err) {
				console.log("跳转", err);
				console.log("跳转toString", err.toString());
			}
			this.setNativeBackFlagForPayIsTrue();
        }
    }
</script>
